package com.zhaolixiang.view.draw1

import android.content.Context
import android.graphics.*
import android.view.View

/**
 * Created by Administrator on 2018/1/1.
 */
class CircleView(context: Context) :View(context){
    override fun onDraw(canvas: Canvas) {
        super.onDraw(canvas)

        //设置画笔属性
        val paint= Paint()
        //抗锯齿功能
        paint.isAntiAlias=true
        //设置画笔颜色
        paint.color= Color.parseColor("#448ced")
        //设置填充样式
        paint.style=Paint.Style.STROKE
        //设置画笔宽度
        paint.strokeWidth=5f
        //设置阴影
        paint.setShadowLayer(10f,10f,10f,Color.RED)

        //设置画布背景色
        canvas.drawColor(Color.WHITE)

        //画圆:圆心坐标，半径，画笔
        canvas.drawCircle(100f,100f,50f,paint)


        //画直线
        canvas.drawLine(100f,100f,200f,200f,paint)

        //画多条直线
        val floatList= floatArrayOf(250f,250f,350f,350f,450f,450f,376f,360f)
        canvas.drawLines(floatList,paint)

        //画点
        canvas.drawPoint(444f,360f,paint)

        //多个点
        val pointList= floatArrayOf(444f,10f,444f,20f,444f,30f)
        canvas.drawPoints(pointList,paint)

        //画矩形
        canvas.drawRect(100f,100f,500f,500f,paint)

        val rectf=RectF(200f,200f,400f,400f)
        canvas.drawRect(rectf,paint)

        val rect= Rect(250,250,350,350)
        canvas.drawRect(rect,paint)

        //圆角半径
        val rect2=RectF(100f,600f,200f,700f)
        canvas.drawRoundRect(rect2,20f,20f,paint)

        //椭圆
        val rectf3=RectF(100f,750f,200f,800f)
        canvas.drawOval(rectf3,paint)

        //画弧
        val rectf4=RectF(100f,800f,200f,850f)
        canvas.drawArc(rectf4,0f,90f,false,paint)




    }
}